const crypto = require('crypto');

module.exports = {

	getRandomId(len) {
		len = parseInt(len) > 0 ? parseInt(len) : 16
		let randomId = crypto.createHash('md5').update(`${Math.random()}`).digest('hex');
		return randomId.slice(0, len)
	},

	/**
	 * 密码加密
	 * @param  {[type]} password [description]
	 * @return {[type]}          [description]
	 */
	encPwd(password) {
		return crypto.createHash('md5').update(password).digest('hex');
	},
}